<template>
	<div class="reg-email-2">
		<step :step="step"></step>
		<table class="table_1_5">
			<tr class="tr1">
				<td colspan="2">
					<router-link to='/reg/email'>使用邮箱注册?</router-link>
				</td>
			</tr>
			<tr class="tr2">
				<td>登录密码</td>
				<td>
					<input type="text" class="text" placeholder="请输入您的手机号码" v-model="code_phone.mobile" />
				</td>
			</tr>
			<tr class="tr2">
				<td>确认登录密码</td>
				<td>
					<input type="text" class="text" placeholder="请输入您的手机号码" v-model="code_phone.mobile" />
				</td>
			</tr>
			<tr class="tr2">
				<td>邀请码 <label style="font-size: 12px;color: silver;">(选填)</label></td>
				<td>
					<input type="text" class="text" placeholder="请输入邀请码"/>
				</td>
			</tr>	
			<!--<tr class="tr1">
					<td></td>
					<td style="padding: 10px 0">
						<input style="margin-right: 10px;: " type="checkbox" />我已经阅读并同意
						<label style="color: #0093F1;">《交易所服务协议》</label>
					</td>
				</tr>-->
			<tr style="text-align: center" class="tr2">
				<td></td>
				<td>
					<button :class="{ 'button_s': unlock_tag && code_phone.mobile && one_p.mcode}" v-on:click="next">下一步</button>
				</td>
			</tr>
		</table>
	</div>
</template>

<script>
	import step from './step'
	export default {
		components: {
			step,
		},
		data() {
			return {
				step: 2,
				register_type: '',
				code_phone: {
					'mobile': '',
					'type': 'nreg',
				},
				two_p: {
					'password': '',
					'cfmpwd': '',
					'icode': '',
				},
				code_tag: 60,
				unlock_tag: false,
			};
		},
		computed: {
	  },
		methods: {
			unlock() {
				this.unlock_tag = true;
			},
			next() {
				var that = this;
				this.lh_http('post', "regStepTwo", this.two_p).done(function(res) {
					if(res.status) {
						console.log(1111);
						
						this.step = 3;
					} else {
						alert(res.data);
					}
				})
			},
			sendSMSCode() {
				if(this.code_tag < 60) {
					return;
				}
				var that = this;
				this.lh_http('post', "sendvcode", this.code_phone).done(function(res) {
					if(res.status) {
						that.runcode();
						alert('请注意查收短信');
					} else {
						alert(res.data);
					}
				})

			},
			verificationCode(type) {
				UserService.verificationCode(this.code_phone);
			},
			runcode() {
				var that = this;
				var run = function() {
					that.code_tag--;
					if(that.code_tag <= 0) {
						clearInterval(timer)
						that.code_tag = 60;
					}
				}
				var timer = setInterval(run, 1000)
			}
		},
		watch: {
			'$refs.unlockref': function(res) {
				console.log(res)
				this.value = res;
			},
			unlock: function(res){
				console.log(res)
			}
		}
		
	};
</script>

<style lang="scss">
	.reg-email-2 {}
</style>